// 1 导入axios
import axios from 'axios'
// 1.1 导入element message组件
import { Message } from 'element-ui'
// 1.2 导入mockjs
import Mock from 'mockjs'


// 2 设置相关参数：基本路径、超时时间 等
axios.defaults.baseURL = 'http://192.168.0.108:10010/api'
axios.defaults.timeout = 3000

// 3 配置拦截器
axios.interceptors.request.use(request=>{
    let token = sessionStorage.getItem('token')
    if(token){
        request.headers.authorization = token
    }
    return request
},error=>{})
axios.interceptors.response.use(response => {
    
    // 放行
    return response
}, error => {
    // 错误提示
    console.info(error)
    Message.error(error.message)
    return Promise.reject(error)
})

// 4 模拟数据
// Mock.mock('请求路径','请求方式',需要数据)
// 4.1 登录模拟数据
/*
Mock.mock('http://localhost:20001/api/v1/access_token','post',)
*/


// 5 所有请求（每一个都是一个功能）
export function test(){
    return axios.get('/test')
}

//添加用户 注册
export function addUser(ruser){
    return axios.post('/userservice/user/addUser',ruser)
}

//查询出所有的类型
//findAllidtype
export function findAllidtype(){
    return axios.get('/userservice/user/findAllidtype')
}

//用户登录
export function login(ruser){
    return axios.post('/userservice/user/login',ruser)
}

//http://localhost:10010/api/userservice/user/findAllUser
//查询所有用户
export function findAllUserForpage(UserVo){
    return axios.post('/userservice/user/findAllUserForpage',UserVo)
}

// 修改 1 根据id查询用户 
export function findOneUserByuid(uid){
    return axios.get('/userservice/user/findOneUserByuid/'+uid)
}
//修改二 传入user 进行修改
export function updateuser(user){
    return axios.put('/userservice/user/updateuser',user)
}

//删除 用户 
// delUserByuid
export function delUserByuid(uid){
    return axios.delete('/userservice/user/delUserByuid/'+uid)
}
//查询所有酒店员工 + 分页 + 条件
export function findAllStaffForpage(staffVo){
    return axios.post('/personservice/staff/findAllStaffForpage',staffVo)
}


//添加一个酒店员工
// addStaff
export function addStaff(staff){
    return axios.post('/personservice/staff/addStaff',staff)
}
//删除  一个员工 根据 hid
// delStaffByHid
export function delStaffByHid(hid){
    return axios.delete('/personservice/staff/delStaffByHid/'+hid)
}

//批量删除 delAllStaffByDir
export function delAllStaffByDir(dir){
    return axios.delete('/personservice/staff/delAllStaffByDir/'+dir)
}

//修改1  根据 hid 查询用户 
export function findOneStaffByhid(hid){
    return axios.get('/personservice/staff/findOneStaffByhid/'+hid)
}

//修改2 修改酒店人员 
export function updateStaff(staff){
    return axios.put('/personservice/staff/updateStaff',staff)
}

//查询出 所有的角色
// findAllRose
export function findAllRose(){
    return axios.get('/personservice/staff/findAllRose')
}

//官网显示所有的房间 + 状态 + 房间内容
//http://localhost:10010/api/guestservice/guest/findAllGuest
export function findAllGuest(guestVo){
    return axios.post('/guestservice/guest/findAllGuest',guestVo)
}

//findAllGuestBook
export function findAllGuestBook(){
    return axios.get('/guestservice/guest/findAllGuestBook')
}

//查询出所有的房间 findAllGuestByAdd 房间类型
export function findAllGuestByAdd(){
    return axios.get('/guestservice/guest/findAllGuestByAdd')
}

//添加房间
export function addGuest(guest){
    return axios.post('/guestservice/guest/addGuest',guest)
}

//订阅房间 入住
export function updateGuest(guest){
    return axios.put('/guestservice/guest/updateGuest',guest)
}

//查询所有的已订阅 用户 进行审核通过 
//http://localhost:10010/api/guestservice/guest/findAllGuestWYYD
export function findAllGuestWYYD(guestVo){
    return axios.post('/guestservice/guest/findAllGuestWYYD',guestVo)
}
 
//查询所有 用户 进行审核通过 房间
export function findAllGuestWTGSH(guestVo){
    return axios.post('/guestservice/guest/findAllGuestWTGSH',guestVo)
}

//查询所有空闲的房间
//findAllGuestKX
export function findAllGuestKX(){
    return axios.get('/guestservice/guest/findAllGuestKX')
}

//修改 审核 通过 
export function updateGuestByRid(rid){
    return axios.put('/guestservice/guest/updateGuestByRid/'+rid)
}

//未通过 审核
export function canceltheorder(rid){
    return axios.put('/guestservice/guest/canceltheorder/'+rid)
}

//changeGuest 更换房间
export function changeGuest(guest){
    return axios.put('/guestservice/guest/changeGuest',guest)
}

//退房
// checkoutGuest
export function checkoutGuest(rid){
    return axios.put('/guestservice/guest/checkoutGuest/'+rid)
}

//删除房间
//deleteGuest
export function deleteGuest(rid){
    return axios.delete('/guestservice/guest/deleteGuest/'+rid)
}

//添加建议
export function declareoneself(suggest){
    return axios.post('/guestservice/suggest/addSuggest',suggest)
}

//查询所有的建议
export function findAllguest(){
    return axios.get('/guestservice/suggest/findAllguest')
}

//删除建议 
export function delBysid(sid){
    return axios.delete('/guestservice/suggest/delBysid/'+sid)
}

//查询 findAllCommodity 商品
export function findAllCommodity(commodityVo){
    return axios.post('/guestservice/commdity/findAllCommodity',commodityVo)
}

//查询欠缺商品 
export function findAllCommodityQS(commodityVo){
    return axios.post('/guestservice/commdity/findAllCommodityQS',commodityVo)
}

//修改 1 商品
export function checkoutBycid(cid){
    return axios.get('/guestservice/commdity/checkoutBycid/'+cid)
}


//修改 2 商品
export function updateCommodity(commodity){
    return axios.put('/guestservice/commdity/updateCommodity',commodity)
}

//已采购 updateCommodityNumber
export function updateCommodityNumber(cid){
    return axios.put('/guestservice/commdity/updateCommodityNumber/'+cid)
}

//查询所哟 health
// findAllHealthBypage
export function findAllHealthBypage(healthVo){
    return axios.post('/guestservice/health/findAllHealthBypage',healthVo)
}

//查询 hid health
export function findOneByhid(hid){
    return axios.get('/guestservice/health/findOneByhid/'+hid)
}

//修改  put updateHealth 卫生的状态
export function updateHealth(health){
    return axios.put('/guestservice/health/updateHealth',health)
}

//删除卫生 根据 hid
export function delhealthbyhid(hid){
    return axios.delete('/guestservice/health/delhealthbyhid/'+hid)
}

//查询所有
// amountofbusiness
export function amountofbusiness(){
    return axios.get('/guestservice/guest/amountofbusiness')
}

//酒店人员管理登录
// loginstaff
export function loginstaff(loginForm){
    return axios.post('/personservice/staff/login',loginForm)
}